package com.supplychainapi.common;

/**
 * 业务层报错信息
 * @author xiezhiwei
 *
 */
public enum BizCode {
	
    SUCCESS(200, "成功"),
    FAIL(500, "失败"),
    PARAM_NULL(5000100, "参数不能为空"),
    PARAM_INVALID(5000101, "参数不正确"),
    PHONE_CODE_INVALID(5000102, "验证码错误"),
    FILE_SERVER_ACCESS_FAIL(5000103, "文件服务地址获取失败"),
    PAGE_NUM_INVALID(5000113, "分页页码错误"),
    PAGE_SIZE_INVALID(5000114, "分页大小错误"),



    USER_SERVICE_FAIL0(500010, "获取用户失败"),
    USER_SERVICE_FAIL1(500011, "修改用户失败"),
    USER_SERVICE_FAIL2(500012, "用户入库失败"),
    USER_SERVICE_FAIL3(500013, "用户TOKEN失效"),
    USER_SERVICE_FAIL4(500111, "用户未绑定手机号码"),
    USER_SERVICE_FAIL5(500115, "非法的用户性别"),
    USER_SERVICE_FAIL6(500116, "手机号码不能为空"),
    USER_SERVICE_FAIL7(500117, "非法的手机号码"),
    USER_SERVICE_FAIL8(500118, "验证码不能为空"),
    USER_SERVICE_FAIL9(500119, "用户TOKEN不存在"),

    SMS_SERVICE_FAIL0(5000020, "短信模板发送失败"),
    SMS_SERVICE_FAIL1(5000021, "短信内容发送失败"),

    FILE_SERVICE_FAIL0(5000030, "文件上传失败"),
    FILE_SERVICE_FAIL1(5000031, "文件下载失败"),
	
	DATA_BASE_ERROR_MESSAGE(5000040,"获取数据异常"),
	SUPPLIER_ERROR_MESSAGE(5000041,"当前供应商名称已存在"),
	STORAGE_ERROR_MESSAGE(5000042,"当前仓库名称已存在"),
    Cust_ERROR_MESSAGE(5000043,"当前供应商名称已存在"),

    SUPPLIER_QUOTE_ERROR_MESSAGE(5000044, "当前供应商名称已被引用"),
    STORAGE_QUOTE_ERROR_MESSAGE(5000045, "当前仓库名称已被引用");




    /** 编码 */
    private Integer num;
    /** 描述 */
    private String desc;

    BizCode(Integer num, String desc) {
        this.num = num;
        this.desc = desc;
    }

    public String getCode(){
        return this.name();
    }

    public static Integer getNumByBizCode(BizCode bizCode){
        for(BizCode item : BizCode.values()){
            if(item.getCode().equals(bizCode.name())){
                return item.getNum();
            }
        }
        return bizCode.getNum();
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
